<template>
  <div
    class="container"
    :class="['top', 'down'][i]"
    v-for="(item, i) in briefingList"
    :key="item.id"
  >
    <div class="img-wrap">
      <img class="top" src="@/assets/images/home/icon-top.png" />
      <img class="down" src="@/assets/images/home/icon-down.png" />
    </div>
    <div class="w1300">
      <div class="simple-item flex">
        <div class="left-wrap">
          <img class="icon" src="@/assets/images/home/ico.png" alt="" />
          <span>公司介绍</span>
          <h2>{{ item.title }}</h2>
          <p v-html="item.text"></p>
        </div>
        <div class="simp-img-wrap">
          <img :src="item.imageUrl" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { reqGetBriefingList } from '@/api'
import { queryBriefingParams, respBriefingListData } from '@/api/types'

const briefingList = ref<respBriefingListData[]>([])
onMounted(async () => {
  let briefingTop = await getBriefingList(0)
  let briefingBottom = await getBriefingList(1)
  if (briefingTop?.id) briefingList.value?.push(briefingTop)
  if (briefingBottom?.id) briefingList.value?.push(briefingBottom)
})

const getBriefingList = async (position: number) => {
  const reqParams: queryBriefingParams = { position }
  let resp = await reqGetBriefingList(reqParams)
  return resp.data
}
</script>

<style lang="scss" scoped>
.container {
  position: relative;

  &.top {
    .img-wrap {
      right: 61px;
    }
  }

  &.down {
    background-color: #f8f8f8;

    .simple-item {
      flex-direction: row-reverse;

      .left-wrap {
        margin-right: 0;
        margin-left: 106px;
      }
    }
  }

  .w1300 {
    .simple-item {
      padding: 52px 0;

      .left-wrap {
        display: flex;
        flex-direction: column;
        width: 760px;
        margin-right: 106px;

        .icon {
          width: 10px;
          height: 10px;
          margin-bottom: 11px;
        }

        > span {
          font-size: 20px;
          color: #77777f;
        }

        > h2 {
          margin: 12px 0 32px;
          font-size: 40px;
          color: $primary;
        }

        > p {
          font-size: 18px;
          line-height: 30px;
          color: #8691a3;
        }
      }

      .simp-img-wrap {
        flex: 1;

        > img {
          width: 430px;
        }
      }
    }
  }
}

.img-wrap {
  position: absolute;
  top: calc((100% - 203px) / 2);

  img {
    position: absolute;
    left: 0;
    width: 61px;

    &.down {
      top: 88px !important;
    }
  }
}
</style>
